package com.lmz.project.redis.arithmetic.threadLearn;

public class ThreadTest extends Thread{
    @Override
    //线程体,启动线程时会运行run()方法中的代码
    public void run() {
        //输出100以内的偶数
        for (int i = 0; i < 10; i++) {
            if (i % 2 == 0){
                System.out.println(Thread.currentThread().getName()+":\t"+i);
            }
        }
    }


    public static void main(String[] args) throws InterruptedException {
        ThreadTest t1 = new ThreadTest();
        t1.setName("线程1");
        t1.start();
        ThreadTest t2 = new ThreadTest();
        t2.setName("线程2");
        t2.start();
        System.out.println("zzzzzzzzzz");
        System.out.println("主线程");

    }
}
